public class Solution {
    public int jewelleryValue(int[][] frame) {
        int m = frame.length;
        int n = frame[0].length;

        //多增加一行和一列
        int[][] ret = new int[m + 1][n + 1];

        //填表
        for (int i = 1; i < m + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                ret[i][j] = Math.max(ret[i - 1][j], ret[i][j - 1]) + frame[i - 1][j - 1];
            }
        }
        return ret[m][n];
    }
}
